﻿@using NewLife.Common;
@using NewLife.Cube.Areas.Admin;
@using XCode.DataAccessLayer;
@{
    //Layout = NewLife.Cube.Setting.Current.Layout;
    var dbs = Model as IList<DbItem>;
}

@section css{
    <style>
        .layui-table-box a:focus, a:hover {
            color: #23527c;
        }

        .layui-table-box a {
            color: #337ab7;
        }
    </style>
}

<div class="layui-fluid" id="mainpage">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-panel">
                <div class="layui-form layui-border-box layui-table-view" style="margin:10px;">
                    <div class="layui-table-box">
                        <div class="layui-table-header">
                            <table class="layui-table" cellspacing="0" cellpadding="0" border="0" lay-size="sm" style="width:100%">
                                <thead>
                                    <tr>
                                        <th>
                                            <div class="layui-table-cell laytable-cell-1-0-0" data-id="1-0-0">
                                                <span>
                                                    名称
                                                </span>
                                            </div>
                                        </th>
                                        <th>
                                            <div class="layui-table-cell laytable-cell-1-0-1" data-id="1-0-1">
                                                <span>
                                                    类型
                                                </span>
                                            </div>
                                        </th>
                                        <th>
                                            <div class="layui-table-cell laytable-cell-1-0-2" data-id="1-0-2">
                                                <span>
                                                    连接字符串
                                                </span>
                                            </div>
                                        </th>
                                        <th>
                                            <div class="layui-table-cell laytable-cell-1-0-3" data-id="1-0-3">
                                                <span>
                                                    版本
                                                </span>
                                            </div>
                                        </th>
                                        <th>
                                            <div class="layui-table-cell laytable-cell-1-0-4" data-id="1-0-4">
                                                <span>
                                                    备份
                                                </span>
                                            </div>
                                        </th>
                                        <th>
                                            <div class="layui-table-cell laytable-cell-1-0-5" data-id="1-0-5">
                                                <span>
                                                    备份并压缩
                                                </span>
                                            </div>
                                        </th>
                                        <th>
                                            <div class="layui-table-cell laytable-cell-1-0-6" data-id="1-0-6">
                                                <span>
                                                    下载表结构
                                                </span>
                                            </div>
                                        </th>
                                    </tr>
                                </thead>
                            </table>
                        </div>
                        <div class="layui-table-body layui-table-main">
                            <table class="layui-table" cellspacing="0" cellpadding="0" border="0" lay-size="sm" style="width:100%">
                                <tbody>
                                    @foreach (var item in dbs)
                                    {
                                        var dal = DAL.Create(item.Name);
                                        var pk = dal.ProtectedKey;

                                        // 密码需要保密
                                        var str = pk.Hide(item.ConnStr);
                                        var str2 = pk.Hide(dal.Db.ConnectionString);

                                        <tr>
                                            <td>
                                                <div class="layui-table-cell laytable-cell-1-0-0" data-id="1-0-0">
                                                    @item.Name
                                                </div>
                                            </td>
                                            <td>
                                                <div class="layui-table-cell laytable-cell-1-0-1" data-id="1-0-1">
                                                    @item.Type
                                                </div>
                                            </td>
                                            <td title="@str2">
                                                <div class="layui-table-cell laytable-cell-1-0-2" data-id="1-0-2">
                                                    @str
                                                </div>
                                            </td>
                                            <td>
                                                <div class="layui-table-cell laytable-cell-1-0-3" data-id="1-0-3">
                                                    @item.Version
                                                </div>
                                            </td>
                                            <td>
                                                <div class="layui-table-cell laytable-cell-1-0-4" data-id="1-0-4">
                                                    @Html.ActionLink("备份", "Backup", new { Name = item.Name })，共 @item.Backups.ToString("n0")个
                                                </div>
                                            </td>
                                            <td>
                                                <div class="layui-table-cell laytable-cell-1-0-5" data-id="1-0-5">
                                                    @Html.ActionLink("备份并压缩", "BackupAndCompress", new { Name = item.Name })
                                                </div>
                                            </td>
                                            <td>
                                                <div class="layui-table-cell laytable-cell-1-0-6" data-id="1-0-6">
                                                    @Html.ActionLink("下载", "Download", new { Name = item.Name })
                                                </div>
                                            </td>
                                        </tr>
                                    }
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

@section scripts{
    <script>
        layui.use(['jquery'], function () {
            var $ = layui.$;

            setTableScroll();
            setTable();
        });
    </script>
}